/* Adapted from Minimal theme by @kepano */
/* Required by @kepane, this is his `buy me a coffee` page https://www.buymeacoffee.com/kepano */
/* MIT License

Copyright (c) 2020-2022 Stephan Ango (@kepano)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/* ================================== */
/* ======== Dataview Cards ========== */
/* ================================== */
/* @settings
name: Cards view for dataview table
description:  ❗cssclass：cards ❗ 
id: dataview-cards-view
settings:
  - 
    id: cards-width
    title: cards width
    title.zh: 定义卡片宽度
    type: variable-number-slider
    default: 138
    format: px
    min: 80
    max: 260
    step: 1
  - 
    id: image-aspect-ratio
    title: image aspect ratio
    title.zh: 设置图片宽高比
    type: variable-select
    default:  3 / 4
    options:
            - 
                label: 1:1
                value: 1 / 1
            - 
                label: 3:4
                value: 3 / 4 
            - 
                label: 2:3
                value: 2 / 3 
            - 
                label: 3:2
                value: 3 /2
            - 
                label: 16:9
                value:  16 / 9
*/

/*********covercards***********/
:root{
  --cards-width: 138px;
  --image-aspect-ratio: 3 /4;
}

@media (max-width: 450px) {
  :root{
      --cards-width: 112.64px;
      }
}

@media (max-width: 375px) {
  :root{
      --cards-width: 102.4px;
      }
}

@media (max-width: 350px) {
  :root{
      --cards-width: 87.04px;
      }
}

img[alt^="bookcover"] {
  border-radius: 8px; 
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}

.theme-light progress::-webkit-progress-bar { 
  background: #cccccc; 
}
.theme-dark progress::-webkit-progress-bar { 
  background: #1a1919; 
}

.cards progress{
  
  position: absolute;
  width: var(--cards-width);
  min-width: none;
  margin-top: -10px;
  margin-left:   calc(var(--cards-width) /2 * -1);
  overflow: hidden;
  height: 4px;
}

.cards progress::before{
  display: none;
}
.is-live-preview.cards progress{
  margin-top: -5px;
}

.cards progress.yellow::-moz-progress-bar { 
  background: #e78f0c; 
}
.cards progress.yellow::-webkit-progress-value  {
  border-radius: 1em;
  background: #e78f0c; 
}

.cards progress.hot::-moz-progress-bar { 
  background: #fa7131dc; 
}
.cards progress.hot::-webkit-progress-value  {
  border-radius: 1em;
  background: #fa7131dc; 
}

.cards table.dataview tbody {
  display:flex;
  margin-left: -0.5em;
  width: 101%;
  flex-flow: wrap;
  
}

@media (max-width:1120px) {
  .cards table.dataview tbody {
      margin-left: -40px;
      padding: 0 40px
  }
}

@media (max-width:960px) {
  .cards table.dataview tbody {
      margin-left: -30px;
      padding: 0 30px
  }
}

@media (max-width:460px) {
  .cards table.dataview tbody {
      padding: 0px;
      margin-left: -20px;
  }
}

.cards table.dataview>tbody>tr {
  display: block;
  width:var(--cards-width);
  height: auto;
  margin-left: 1.2em;
  margin-bottom: 1em;
  background-color:transparent;
}

@media (max-width:1120px) {
  .cards table.dataview>tbody>tr {
    margin-left: 40px
  }
}

@media (max-width:960px) {
  .cards table.dataview>tbody>tr {
    margin-left: 30px
  }
}

@media (max-width:460px) {
  .cards table.dataview>tbody>tr {
    margin-left: 20px;
    margin-bottom: 20px
  }
}
.cards .dataview.table-view-table button {
  text-align: left;
  padding-left: 0.8em;
}

.cards table.dataview tbody>tr>td:first-child, 
.markdown-source-view.mod-cm6.cards .dataview.table-view-table>tbody>tr>td:first-child { 
  width: 100%;
  display: block;
  box-shadow: 0 2px 16px rgba(0, 0, 0, .1);
  position: relative;
  padding: 0;
}

.cards table.dataview tbody>tr>td img {
  
  aspect-ratio: var(--image-aspect-ratio);
  vertical-align: top;
  width: 100%;
  height: auto;
  background-color:var(--background-secondary);
  -o-object-fit: cover;
  object-fit: cover;
}
.cards table.dataview tbody>tr>td:first-child:before
{
display: none;
}
.cards table.dataview tbody>tr>td:first-child:after{
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-image: linear-gradient(90deg, hsla(0, 0%, 63.1%, .25), rgba(21, 21, 20, .1) 1%, hsla(0, 0%, 100%, .15) 4%, hsla(0, 0%, 58%, .1) 8%, hsla(0, 0%, 89%, 0) 57%, rgba(223, 218, 218, .03) 91%, rgba(223, 218, 218, .05) 98%, hsla(0, 0%, 100%, .1));
  box-shadow: inset 0 0 0 0 rgba(0, 0, 0, .1);
}
.cards table.dataview tbody>tr>td:not(:first-child), 
.markdown-source-view.mod-cm6.cards .dataview.table-view-table>tbody>tr>td:not(:first-child) {
  text-align: center;
  padding: 0;
  margin-top: 4px;
  font-size: 15px;
  color: var(--text-muted);
  line-height: 18px;
  overflow: hidden;
  display: -webkit-box;
  display: -moz-box;
  -webkit-line-clamp: 2;
  -moz-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  -webkit-text-size-adjust: none;
  box-orient: vertical;
  height: auto;
  font-size: 13px;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cards table.dataview tbody>tr>td button {
  font-size: 12px;
  background-color: transparent;
  padding: 0;
}
.cards table.dataview tbody>tr>td:nth-child(2) {
  margin-top: 10px;
}
.cards table.dataview tbody>tr>td:nth-child(3) {
  -webkit-text-stroke: 0.25px ;
}
/*------------*/

.cards table.dataview thead {
  user-select: none;
  width: 160px;
  display: block;
  float: right;
  position: relative;
  text-align: right;
  padding-bottom: 4px
}
.cards table.dataview thead:before {
  content: '';
  background-repeat: no-repeat;
  cursor: var(--cursor);
  text-align: right;
  padding: 4px 10px;
  margin-bottom: 2px;
  border-radius: 5px;
  font-weight: 500;
  font-size: var(--font-adaptive-small);
}
.cards table.dataview thead:before {
  opacity: .25;
  background-position: center center;
  background-size: 18px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 100 100"><path fill="white" d="M49.792 33.125l-5.892 5.892L33.333 28.45V83.333H25V28.45L14.438 39.017L8.542 33.125L29.167 12.5l20.625 20.625zm41.667 33.75L70.833 87.5l-20.625 -20.625l5.892 -5.892l10.571 10.567L66.667 16.667h8.333v54.883l10.567 -10.567l5.892 5.892z"></path></svg>');
}
.theme-light .cards table.dataview thead:before {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 100 100"><path fill="black" d="M49.792 33.125l-5.892 5.892L33.333 28.45V83.333H25V28.45L14.438 39.017L8.542 33.125L29.167 12.5l20.625 20.625zm41.667 33.75L70.833 87.5l-20.625 -20.625l5.892 -5.892l10.571 10.567L66.667 16.667h8.333v54.883l10.567 -10.567l5.892 5.892z"></path></svg>');
}
.cards table.dataview thead:hover:before {
  opacity: .5;
}
.cards table.dataview thead>tr {
  position: absolute;
  display: none;
  z-index: 9;
  border: 1px solid var(--background-modifier-border);
  background-color: var(--background-secondary);
  box-shadow: 0 2px 8px var(--background-modifier-box-shadow);
  padding: 6px;
  border-radius: 6px;
  flex-direction: column;
  margin: 0;
  width: 100%;
}
.cards table.dataview thead:hover>tr{
  display: flex;
}
.cards table.dataview thead>tr>th{
  display: block;
  background-color: var(--background-primary);
  padding: 3px 30px 3px 6px!important;
  border-radius: 5px;
  width: 100%;
  font-weight: 400;
  color: var(--text-muted);
  border: none;
  font-size: var(--font-adaptive-small);
}
.cards table.dataview thead>tr>th[sortable-style=sortable-asc],
.cards table.dataview thead>tr>th[sortable-style=sortable-desc] {
  color: var(--text-normal)
}
.cards table.dataview thead>tr>th:hover {
  color: var(--text-normal);
  background-color: var(--background-secondary);
}

:is(.markdown-source-view,.markdown-preview-view,.markdown-rendered).cards .block-language-dataview table {
  box-shadow: none;
}